package com.fjeld.client.gui.screens.node;

import com.fjeld.swingx.JTransparentPanel;
import com.fjeld.middleware.jaxb.V1ID;
import com.fjeld.middleware.jaxb.V1Node;
import com.fjeld.client.util.cache.ClientCacheManager;
import com.fjeld.client.gui.util.factories.LabelFactory;
import com.fjeld.client.gui.control.navigation.NavigationEnum;
import com.fjeld.client.gui.screens.ActionTab;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.Observer;
import java.util.Observable;

import org.apache.log4j.Logger;

/**
 * Created by IntelliJ IDEA.
 * User: fjelds
 * Date: Mar 21, 2010
 * Time: 10:02:37 PM
 *
 *
 */
public class ActionView extends JTransparentPanel implements Observer, MouseListener
{
    private static final Logger logger = Logger.getLogger(ActionView.class);
    private static final ClientCacheManager CCM = ClientCacheManager.getInstance();
    private V1Node actionNode;

    public ActionView(V1ID actionID)
    {
        actionNode = CCM.getNode(actionID.getNodeID());
        JLabel label = LabelFactory.createHeaderLabel(actionNode.getName());
        label.addMouseListener(this);

        JLabel progressActionLabel = LabelFactory.createLinkLabel(actionNode);
        progressActionLabel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent mouseEvent)
            {

            }
        });

        JTransparentPanel p = new JTransparentPanel();
        p.add(label, BorderLayout.CENTER);
        p.add(progressActionLabel, BorderLayout.EAST);

        add(p, BorderLayout.NORTH);
        actionNode.addObserver(this);
    }

    public void update(Observable observable, Object o)
    {

    }

    public void mouseClicked(MouseEvent mouseEvent)
    {
        logger.info("Clicked");
        ((ActionCommandsView)NavigationEnum.ACTION_EDIT.getContentPanel()).setCommands(actionNode);
        ActionTab.ACTION_TAB.setContentView(NavigationEnum.ACTION_EDIT);
    }

    public void mousePressed(MouseEvent mouseEvent)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public void mouseReleased(MouseEvent mouseEvent)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public void mouseEntered(MouseEvent mouseEvent)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public void mouseExited(MouseEvent mouseEvent)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
